package com.hy.main.demo.controller;

import com.hy.main.handler.AbstractHandle;
import com.hy.main.handler.StrategyFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author yang DongYong
 * @Date 2022/4/27 - 04 - 27 - 3:41
 * @Description: com.hy.main.demo.controller
 * @version: 1.0
 */
@Slf4j
@RestController
public class ReaderImgController {

    /**
     * RequestParam接收的是key-value里面的参数(URL中的参数)，
     * 通常用于接收GET请求的参数（POST也能接收只接收URL里的，请求体的接收不到）
     * 简易版上传图片Demo
     *
     * @throws IOException
     */
    @PostMapping("/uploading")
    public void readerImg(@RequestParam("fileImg") Integer PayType) throws IOException {
        AbstractHandle invokeStrategy = StrategyFactory.getInvokeStrategy(PayType);
        invokeStrategy.pay01(PayType);
    }

    @PostMapping("/getCookie")
    public void getCookie(HttpServletResponse response) {
         Cookie cookie = new Cookie("Admin_123","9999999966666666666");
         response.addCookie(cookie);
    }


    public static void main(String[] args) throws ParseException {

                SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
                SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date date = inputFormat.parse("2024-12-08 21:43:28.0");
                 outputFormat.format(date);

    }




}
